package com.vhans.aapi.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.vhans.core.web.controller.BaseController;
import com.vhans.core.web.model.Result;
import com.vhans.core.web.page.TableDataInfo;
import com.vhans.db.model.dto.ConditionDTO;
import com.vhans.db.model.dto.groupmsg.GroupMsgDTO;
import com.vhans.db.model.vo.groupmsg.GroupMsgInfoVO;
import com.vhans.db.model.vo.groupmsg.GroupMsgVO;
import com.vhans.db.service.ICGroupMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 群聊天信息Controller控制器
 *
 * @author vhans
 * @date 2023-05-21
 */
@Api(tags = "群聊天信息模块")
@RestController
@RequestMapping("/admin/groupMsg")
public class GroupMsgController extends BaseController {
    @Autowired
    private ICGroupMsgService cGroupMsgService;

    /**
     * 查询群聊天信息列表
     *
     * @param condition 条件
     * @return {@link GroupMsgVO} 题目列表
     */
    @ApiOperation(value = "查询群聊天信息列表")
    @SaCheckPermission("chat:groupMsg:list")
    @GetMapping("/list")
    public TableDataInfo list(ConditionDTO condition) {
        startPage();
        List<GroupMsgVO> list = cGroupMsgService.selectGroupMsgVOList(condition);
        return getDataTable(list);
    }

    /**
     * 获取群聊天信息详细信息
     *
     * @param id 群聊天信息id
     * @return {@link Result<GroupMsgInfoVO>} 群聊天信息信息
     */
    @ApiOperation(value = "获取群聊天信息编辑信息")
    @SaCheckPermission("chat:groupMsg:query")
    @GetMapping(value = "/info/{id}")
    public Result<GroupMsgInfoVO> getInfo(@PathVariable("id") Integer id) {
        return Result.success(cGroupMsgService.selectGroupMsgInfoById(id));
    }

    /**
     * 删除群聊天信息
     *
     * @param idList 需要删除的群聊天信息主键列表
     * @return {@link Result<>}
     */
    @ApiOperation(value = "删除群聊天信息")
    @SaCheckPermission("chat:groupMsg:delete")
    @DeleteMapping("/delete")
    public Result<?> delete(@RequestBody List<Integer> idList) {
        return toAjax(cGroupMsgService.deleteGroupMsgByIdIdList(idList));
    }
}
